/* ========================================================================== */
/*   GameTime.h                                                               */
/*   (c) 2012 Team 7 Hogeschool Utrecht ICT TI								  */
/*		Lars Stolwijk, Gerben Boot, Guido van Hienen, Marcel Boelen			  */
/*                                                                            */
/*   Tracking and sharing gametime (in seconds), gives signal when the		  */
/*		playtime is identical to the gametime.								  */
/* ========================================================================== */

#ifndef __GameTime
#define __GameTime

#include "pRTOS.h"
#include "ProcessHitController.h"
#include "GameHandler.h"
#include "Config.h"

class ProcessHitController;
class GameHandler;

class GameTime : public RTOS::task {
	public:	
		//Constructor
		GameTime(int prio, ProcessHitController * processHitController) : RTOS::task(prio, "GameTimeTask"),theProcessHitController(processHitController), GTTClock( this, 1 S, "GTTClock"), StartStopGameTimeFlag( this, "StartStopGameTimeFlag"){}
		
		void StartStopGameTime();
		void RegisterGameHandler(GameHandler * gameHandler);
	
	private:
		enum State { WAITING, RUNNING };
		State CurrentState;

		short gameTime;
		short time;
		
		ProcessHitController * theProcessHitController;
		GameHandler * theGameHandler;
		
		RTOS::clock GTTClock;
		RTOS::flag StartStopGameTimeFlag;

		void main();
};

#endif
